@@ -0,0 +1 @@ |
||
| 1 |
+/node_modules |
@@ -0,0 +1,8 @@ |
||
| 1 |
+<script src="/socket.io/socket.io.js"></script> |
|
| 2 |
+<script> |
|
| 3 |
+ var socket = io.connect('http://localhost:3100');
|
|
| 4 |
+ socket.on('news', function (data) {
|
|
| 5 |
+ console.log(data); |
|
| 6 |
+ socket.emit('my other event', { my: 'data' });
|
|
| 7 |
+ }); |
|
| 8 |
+</script> |
@@ -0,0 +1,19 @@ |
||
| 1 |
+var winston = require('winston');
|
|
| 2 |
+var app = require('express')();
|
|
| 3 |
+var server = require('http').Server(app);
|
|
| 4 |
+var io = require('socket.io')(server);
|
|
| 5 |
+ |
|
| 6 |
+server.listen(3100, function () {
|
|
| 7 |
+ winston.info('Listening on port 3100');
|
|
| 8 |
+}) |
|
| 9 |
+ |
|
| 10 |
+app.get('/', function (req, res) {
|
|
| 11 |
+ res.sendFcile(__dirname + '/index.html'); |
|
| 12 |
+}); |
|
| 13 |
+ |
|
| 14 |
+io.on('connection', function (socket) {
|
|
| 15 |
+ socket.emit('news', { hello: 'world' });
|
|
| 16 |
+ socket.on('my other event', function (data) {
|
|
| 17 |
+ winston.info("Receiveid data", data);
|
|
| 18 |
+ }); |
|
| 19 |
+}); |
@@ -0,0 +1,16 @@ |
||
| 1 |
+{
|
|
| 2 |
+ "name": "home-automation", |
|
| 3 |
+ "version": "0.0.1", |
|
| 4 |
+ "description": "Personal home automation system", |
|
| 5 |
+ "main": "index.js", |
|
| 6 |
+ "scripts": {
|
|
| 7 |
+ "test": "echo \"Error: no test specified\" && exit 1" |
|
| 8 |
+ }, |
|
| 9 |
+ "author": "James Peret <james.peret@gmail.com> (http://jamesperet.com)", |
|
| 10 |
+ "license": "ISC", |
|
| 11 |
+ "dependencies": {
|
|
| 12 |
+ "express": "^4.15.4", |
|
| 13 |
+ "socket.io": "^2.0.3", |
|
| 14 |
+ "winston": "^2.3.1" |
|
| 15 |
+ } |
|
| 16 |
+} |